#include "VEnginePCH.h"
#include "VUIPicture.h"


UIMP_CLASS(VUIPicture, VUIControl);

VUIPicture::VUIPicture(void):m_Sprite(0)
{

}

VUIPicture::~VUIPicture(void)
{
	if (m_Sprite)
	{
		delete m_Sprite;
	}
}

BOOL VUIPicture::SetSprite(const char* SpriteName)
{
	return TRUE;
}

BOOL VUIPicture::SetSprite(VSprite* Sprite)
{
	if (m_Sprite)
	{
		delete m_Sprite;
	}
	m_Sprite = Sprite;
	return TRUE;
}

BOOL VUIPicture::SetTexture(const char* TextureName)
{
	return TRUE;
}

BOOL VUIPicture::SetTexture(VRTexture* Texture)
{
	if (!m_Sprite)
	{
		m_Sprite = new VSprite;
	}
	if(m_Sprite->InitTexture(Texture))
	{
		return TRUE;
	}
	delete m_Sprite;
	return FALSE;
}

void VUIPicture::OnRender()
{
	if (m_Sprite)
	{
		m_Sprite->Draw(m_ScreenSpacePos.x, m_ScreenSpacePos.y, m_Size.x, m_Size.y);
	}
	DrawChilds();
}
